package com.ruanjian.api.controller;

import com.ruanjian.api.bean.Initial;
import com.ruanjian.api.service.IInitialService;
import com.ruanjian.api.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author shkstart
 * @create 2022-11-30 10:34
 */
@RestController
@RequestMapping("/api/java/Initial")
public class InitialController extends BaseController{

    /**
     * 增加
     * @param record
     * @return
     */
    @CrossOrigin
    @PostMapping("/insertSelective")
    public int insertSelective(@RequestBody Initial record){
        return initialService.insertSelective(record);
    }

    /**
     * 修改
     * @param record
     * @return
     */
    @CrossOrigin
    @PostMapping("/updateByExperimentIdSelective")
    public int updateByExperimentIdSelective(@RequestBody Initial record) {
        return initialService.updateByExperimentIdSelective(record);
    }

    /**
     * 查询所有字段根据实验场次id
     * @param experimentId
     * @return
     */
    @CrossOrigin
    @PostMapping("/selectAllByExperimentId/{experimentId}")
    public AjaxResult selectAllByExperimentId(@PathVariable("experimentId") Long experimentId){
        return AjaxResult.success().add("all",initialService.selectAllByExperimentId(experimentId));
    }

}
